// MSP430 Launchpad - Blink onboard LED using onboard Switch (SW1).
 
#include  "msp430g2231.h" // Include the necessary header for our target MCU
 
void delay_ms(unsigned int ms ){ 		// Not really a milliseconds delay!
      unsigned int i;
      for (i = 0;i<= ms; i++){ 		// The operator is <=, I've yet to fix this site bug.
        __delay_cycles(500);
      }
}
 
void do_led( int led, int delay ) {
	P1OUT = led;
	delay_ms( delay );
}
 
void main(void) {
 
	WDTCTL = WDTPW + WDTHOLD;		// Hold the WDT (WatchDog Timer)
	P1DIR |= BIT7|BIT3|BIT4|BIT5;       		// Setup the appropriate output bits	
	while(1) {
 
		/*if (!(P1IN & BIT2) ){		// If not (port one input AND bit3 (sw1))
			P1OUT &= ~BIT3;//bit5 =0
			P1OUT |= BIT6;//bit7 =1
		P1OUT |= BIT4;
		P1OUT &= ~BIT5;
			
		P1OUT &= ~BIT3;
		P1OUT |= BIT4;
		P1OUT |= BIT5;
		P1OUT |= BIT7;
	delay_ms( 500);			//do_led( BIT6, 2000 );	// Turn on LED 2
		}else{				// Otherwise...
			P1OUT &= ~BIT6;
			P1OUT |= BIT3;
		P1OUT &= ~BIT4;
		P1OUT |= BIT5;
	/*	P1OUT |= BIT3;
		P1OUT |= BIT4;
		P1OUT &= ~BIT5;
		P1OUT |= BIT7;
	*/delay_ms( 500);			//do_led( BIT0, 100 );	// Turn on LED 1
	//	}
 
	//}
 
//}
	if(!(P1IN & BIT2))
		{	  
		P1OUT &= ~BIT3;
		P1OUT &= ~BIT4;
		P1OUT &= ~BIT5;
		P1OUT &= ~BIT7;
		}  
		else //if((P1IN & BIT2))
		{	  
		P1OUT &= ~BIT3;
		P1OUT &= ~BIT4;
		P1OUT |= BIT5;
		P1OUT |= BIT7;
		} 
	/*	else if(!(P1IN & BIT2)rxBuffer =='C')
		{	  
		P1OUT &= ~BIT3;
		P1OUT &= ~BIT4;
		P1OUT &= ~BIT5;
		P1OUT |= BIT7;
		} 
		else if(rxBuffer =='D')
		{	  
		P1OUT &= ~BIT3;
		P1OUT &= ~BIT4;
		P1OUT |= BIT5;
		P1OUT &= ~BIT7;
		} 
		*/}
}
